#include <iostream>
#include <numeric>
#include <string>

class Solution
{
public:
    int main()
    {
        int a, b, c;
        int A, B, C;
        std::cin >> a >> b >> c;
        A = std::min(std::min(a, b), c);
        C = std::max(std::max(a, b), c);
        B = a + b + c - A - C;
        std::string ABC;
        std::cin >> ABC;
        for (char c : ABC)
        {
            if (c == 'A')
            {
                std::cout << A << " ";
            }
            else if (c == 'B')
            {
                std::cout << B << " ";
            }
            else if (c == 'C')
            {
                std::cout << C << " ";
            }
        }
        return 0;
    }
};

#ifndef __LOCAL_TEST__
int main()
{
    return Solution().main();
}
#endif